imcontextxim: Move initialisation into _init function
authorTimm Bäder <mail@baedert.org>
Sun, 4 Mar 2018 18:55:54 +0000 (19:55 +0100)
committerTimm Bäder <mail@baedert.org>
Sun, 4 Mar 2018 18:55:54 +0000 (19:55 +0100)
We are creating these using g_object_new, so the _new function is never
called, resulting in a NULL mb_charset. Fix this by moving the
initialisation into the _init function.

gtk/gtkimcontextxim.c
gtk/gtkimcontextxim.h

index 8c84c54146a78e32dd440e44e9c0ee2a75e39ae5..caaaf0328054df52e266e8772b57b623c9d19ef0 100644 (file)
@@ -467,11 +467,18 @@ gtk_im_context_xim_class_init (GtkIMContextXIMClass *class)
 static void
 gtk_im_context_xim_init (GtkIMContextXIM *im_context_xim)
 {
+  const char *charset;
+
   im_context_xim->use_preedit = TRUE;
   im_context_xim->filter_key_release = FALSE;
   im_context_xim->finalizing = FALSE;
   im_context_xim->has_focus = FALSE;
   im_context_xim->in_toplevel = FALSE;
+
+  im_context_xim->locale = g_strdup (setlocale (LC_CTYPE, NULL));
+
+  g_get_charset (&charset);
+  im_context_xim->mb_charset = g_strdup (charset);
 }
 
 static void
@@ -583,24 +590,6 @@ gtk_im_context_xim_set_client_widget (GtkIMContext *context,
   set_ic_client_window (context_xim, window);
 }
 
-GtkIMContext *
-gtk_im_context_xim_new (void)
-{
-  GtkIMContextXIM *result;
-  const gchar *charset;
-
-  if (!GDK_IS_X11_DISPLAY(gdk_display_get_default()))
-    return NULL;
-  result = g_object_new (GTK_TYPE_IM_CONTEXT_XIM, NULL);
-
-  result->locale = g_strdup (setlocale (LC_CTYPE, NULL));
-
-  g_get_charset (&charset);
-  result->mb_charset = g_strdup (charset);
-
-  return GTK_IM_CONTEXT (result);
-}
-
 static char *
 mb_to_utf8 (GtkIMContextXIM *context_xim,
            const char      *str)
index 5965c65b007ad83564dcacc61e91da764b01217f..4d31479d4b8f78cfbfcbcdb7a2fcaeda6d13367f 100644 (file)
@@ -40,7 +40,6 @@ struct _GtkIMContextXIMClass
 };
 
 GType         gtk_im_context_xim_get_type (void) G_GNUC_CONST;
-GtkIMContext *gtk_im_context_xim_new      (void);
 void          gtk_im_context_xim_shutdown (void);
 
 G_END_DECLS